package com.example.oasystem.dao.file;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.oasystem.entity.file.AoaFileList;
import com.example.oasystem.entity.file.AoaFilePath;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface AoaFileListDao extends BaseMapper<AoaFileList> {

    List<AoaFileList> selectAllDocument(Long pathId);

    List<AoaFileList> selectAllImages(Long pathId);

    List<AoaFileList> selectAllMusic(Long pathId);
    //通过fileid获取filelist
    AoaFileList selectOneFlist(int fileid);

    //修改文件名字
    Integer updateFileName(@Param("newname") String newname, @Param("fileid") Integer fileid);

    //查询当前目录
    AoaFilePath findFpOne(@Param("pathid") int pathid);
    @Select("select count(*) from aoa_file_path where path_name=#{name} and parent_id=#{parentid} and path_user_id=#{userid}")
    Integer selectFiles(@Param("name") String name,@Param("parentid") Long parentid,@Param("userid") Long userid);
    //修改文件夹名字
    Integer updateFilesName(@Param("name") String name,@Param("pathid") Integer pathid);

    // 更改文件状态
    @Update("update aoa_file_list set path_id=#{pathId} where file_id=#{fileId}")
    Integer saveflistplus(AoaFileList filelist);

    Integer saveflist(AoaFileList fileList);
}